package com.ruoyi.finance.normalRecharge.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.finance.normalRecharge.domain.FiNormalRecharge;
import com.ruoyi.finance.normalRecharge.service.IFiNormalRechargeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 普通充值Controller
 * 
 * @author wangmh
 * @date 2023-09-17
 */
@RestController
@RequestMapping("/finance/normalRecharge")
public class FiNormalRechargeController extends BaseController
{
    @Autowired
    private IFiNormalRechargeService fiNormalRechargeService;

    /**
     * 查询普通充值列表
     */
    @PreAuthorize("@ss.hasPermi('finance:normalRecharge:list')")
    @GetMapping("/list")
    public TableDataInfo list(FiNormalRecharge fiNormalRecharge)
    {
        startPage();
        List<FiNormalRecharge> list = fiNormalRechargeService.selectFiNormalRechargeList(fiNormalRecharge);
        return getDataTable(list);
    }

    /**
     * 导出普通充值列表
     */
    @PreAuthorize("@ss.hasPermi('finance:normalRecharge:export')")
    @Log(title = "普通充值", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FiNormalRecharge fiNormalRecharge)
    {
        List<FiNormalRecharge> list = fiNormalRechargeService.selectFiNormalRechargeList(fiNormalRecharge);
        ExcelUtil<FiNormalRecharge> util = new ExcelUtil<FiNormalRecharge>(FiNormalRecharge.class);
        return util.exportExcel(list, "普通充值数据");
    }

    /**
     * 获取普通充值详细信息
     */
    @PreAuthorize("@ss.hasPermi('finance:normalRecharge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fiNormalRechargeService.selectFiNormalRechargeById(id));
    }

    /**
     * 新增普通充值
     */
    @PreAuthorize("@ss.hasPermi('finance:normalRecharge:add')")
    @Log(title = "普通充值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FiNormalRecharge fiNormalRecharge)
    {
        return toAjax(fiNormalRechargeService.insertFiNormalRecharge(fiNormalRecharge));
    }

    /**
     * 修改普通充值
     */
    @PreAuthorize("@ss.hasPermi('finance:normalRecharge:edit')")
    @Log(title = "普通充值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FiNormalRecharge fiNormalRecharge)
    {
        return toAjax(fiNormalRechargeService.updateFiNormalRecharge(fiNormalRecharge));
    }

    /**
     * 删除普通充值
     */
    @PreAuthorize("@ss.hasPermi('finance:normalRecharge:remove')")
    @Log(title = "普通充值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fiNormalRechargeService.deleteFiNormalRechargeByIds(ids));
    }
}
